﻿using DevExpress.Data.Filtering.Helpers;
using DevExpress.XtraEditors.Filtering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;


//数据模型类
namespace 机器组和机器编辑
{
    internal class MachineGroup
    {
        public int GroupID { get; set; } //机器组编号
        public string GroupName { get; set; } //机器组名称
        public bool GroupConfiguration { get; set; } //配置
        public string Language { get; set; } //配置语言
        public string GroupType { get; set; } //类型

        public MachineGroup() { }

        public MachineGroup(int groupID, bool groupConfiguration, string groupName, string language, string grouptype)
        {
            GroupID = groupID;
            GroupName = groupName;
            Language = language;
            GroupConfiguration = groupConfiguration;
            GroupType = grouptype;
        }

        //历史xml文件数据加载
        public static MachineGroup FromXElement(XElement xe)
        {
            return new MachineGroup
            {
                GroupID = (int)xe.Attribute("id"),
                GroupName = (string)xe.Attribute("name"),
                GroupConfiguration = (bool)xe.Attribute("configuration"),
                Language = (string)xe.Attribute("language"),
                GroupType = (string)xe.Attribute("type")
            };
        }

        public XElement ToElement()  //映射为xml元素
        {
            return new XElement("MachineGroup",
                new XAttribute("id", GroupID),
                new XAttribute("name", GroupName),
                new XAttribute("configuration", GroupConfiguration),
                new XAttribute("language", Language),
                new XAttribute("type", GroupType)
                );
        }
    }
}
